home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-21 | 3.2 KB | 109 lines | [TEXT/ToyS] |
-
- -- Enter here your Commandline
- set CommandLine to "zip -r archive *"
-
- try
- tell application "MacZip crypt (FAT)"
- activate
- with timeout of 90000 seconds
- -- uncomment the following command to suppress warning
- -- boxes for switches -m and -df
- -- do_cmd "NoWarningBoxes"
- do_cmd CommandLine
- end timeout
- quit
- end tell
- on error number ErrorNumber
- beep 1
- activate
- -- unfortunately there is a overlap of the errorcodes
- -- so we need to distinguish between zip and unzip
- if CommandLine starts with "zip" then ¬
- ZipErrorHandler(CommandLine, ErrorNumber)
- if CommandLine starts with "unzip" then ¬
- UnzipErrorHandler(CommandLine, ErrorNumber)
- end try
-
-
-
-
- on ZipErrorHandler(ErrorMessage, ErrorNumber)
- -- Error return values. The values 0..4 and 12..18 follow the conventions
- -- of PKZIP. The values 4..10 are all assigned to "insufficient memory"
- -- by PKZIP, so the codes 5..10 are used here for other purposes.
- try
- set TempErrNum to ErrorNumber
- if ErrorNumber = 80 then set TempErrNum to 19
- item TempErrNum of {¬
- " unknown ", ¬
- " unexpected end of zip file ", ¬
- " zip file structure error ", ¬
- " out of memory ", ¬
- " internal logic error ", ¬
- " entry too large to split ", ¬
- " invalid comment format ", ¬
- " zip test (-T) failed or out of memory ", ¬
- " user interrupt or termination ", ¬
- " error using a temp file ", ¬
- " read or seek error ", ¬
- " nothing to do ", ¬
- " missing or empty zip file ", ¬
- " error writing to a file ", ¬
- " couldn't open to write ", ¬
- " bad command line ", ¬
- " unknown ", ¬
- " could not open a specified file to read ", ¬
- " user hit [command] + [.] to terminate "}
- on error
- set result to "Unknown Error"
- end try
- display dialog ¬
- "Command failed: " & return & "[" & ErrorMessage & ¬
- "]" & return & "\"" & result & " \"" & return ¬
- & "Result Code: " & ErrorNumber buttons {"Ooops"} default button 1 ¬
- with icon stop
-
- end ZipErrorHandler
-
-
-
-
- on UnzipErrorHandler(ErrorMessage, ErrorNumber)
- try
- set TempErrNum to ErrorNumber
- if ErrorNumber = 50 then set TempErrNum to 12
- if ErrorNumber = 51 then set TempErrNum to 13
- if ErrorNumber = 80 then set TempErrNum to 14
- if ErrorNumber = 81 then set TempErrNum to 15
- if ErrorNumber = 82 then set TempErrNum to 16
-
- item TempErrNum of {¬
- " warning error ", ¬
- " error in zipfile ", ¬
- " severe error in zipfile ", ¬
- " insufficient memory (during initialization) ", ¬
- " insufficient memory (password failure) ", ¬
- " insufficient memory (file decompression) ", ¬
- " insufficient memory (memory decompression) ", ¬
- " insufficient memory (not yet used) ", ¬
- " zipfile not found ", ¬
- " bad or illegal parameters specified ", ¬
- " no files found ", ¬
- " disk full ", ¬
- " unexpected EOF ", ¬
- " user hit [command] + [.] to terminate ", ¬
- " no files found: all unsup. compr/encrypt. ", ¬
- " no files found: all had bad password "}
- on error
- set result to "Unknown Error"
- end try
- display dialog ¬
- "Command failed: " & return & "[" & ErrorMessage & ¬
- "]" & return & "\"" & result & " \"" & return ¬
- & "Result Code: " & ErrorNumber buttons {"Ooops"} default button 1 ¬
- with icon stop
- end UnzipErrorHandler
-
-
-
-